<script setup lang="ts">
  import { ElButton } from 'element-plus'
import { nextTick, ref, onBeforeUnmount, onUnmounted } from 'vue';
import TestJson from '../count.json'
import { SeUseExcel } from '../use-excel'
let uApi:SeUseExcel;
function init(){
  const seUniver = new SeUseExcel("pre-view", TestJson as any)
  uApi = seUniver
}
function getData() {
  const savedData = uApi.univerAPI?.getActiveWorkbook()?.save();
  console.log('savedData: ', savedData);
}
nextTick(()=>{
  init()
})
onBeforeUnmount(()=>{
  uApi?.dispose()
  uApi?.univer?.dispose()
  console.log("卸载前", uApi.univerAPI)
})
onUnmounted(()=>{
  console.log("卸载后", uApi.univerAPI)
})
</script>

<template>
  <div>
    <ElButton @click="getData">获取数据</ElButton>
  </div>
  <div id="pre-view"></div>
</template>

<style scoped>
 #pre-view{
  height: 80vh;
 }
</style>
